package com.ffcs.web.utils;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.ConfigurationFactory;
import org.apache.log4j.Logger;

/**
 * @Title: CommonConfig.java 
 * @Package com.ffcs.eeup.utils 
 * @Description:汇集系统所有的配置信息
 * @Copyright: Copyright (c) 2010 FFCS All Rights Reserved
 * @author Yujl
 * @date 2014年6月5日 下午7:59:43 
 * @version V1.00.00 
 */
@SuppressWarnings("deprecation")
public class CommonConfig {
	private static Logger logger = Logger.getLogger(CommonConfig.class);
	
	private static final String configurationFilePath = "config.xml";
	
	private static Configuration config ;

	static{
		//1.获取classpath
//		File classPathFile = new File(ClassLoader.getSystemResource("").getFile());
//		String classPath = classPathFile.getAbsolutePath();
        String filePath = Thread.currentThread().getContextClassLoader().getResource(configurationFilePath).getPath();

		//2.归并配置信息
		ConfigurationFactory factory = new ConfigurationFactory(filePath);
		try {
			config = factory.getConfiguration();
		} catch (ConfigurationException e) {
			logger.fatal("归并配置信息出错！",e);
			System.exit(-1);
		}
	}
	
	public static String getProperty(String propertyName){
		return config.getString(propertyName);
	}
	
	public static Integer getInt(String propertyName){
		return config.getInt(propertyName);
	}
	
	public static void main(String[] args) {
		System.out.println(CommonConfig.getProperty("IM_USER_SYNC_URL"));
	}
}

